package cn.edu.scau.cmi.linyiling.composite.consistent;

import java.util.HashSet;
import java.util.Set;

public class ConsistentComposite implements ConsistentComponent {
	private String name;
	private ConsistentComponent parent;
	private Set<ConsistentComponent> children = new HashSet<ConsistentComponent>();
	
	public ConsistentComposite(String a) {
		this.name = a;
	}
	
	public void addP(ConsistentComponent c) {
		this.parent = c;
	}
	
	@Override
	public String doSomething() {
		return this.name;
	}

	@Override
	public ConsistentComponent getParent() {
		return this.parent;
	}

	@Override
	public void addChild(ConsistentComponent c) {
		this.children.add(c);
	}

	@Override
	public void delete(ConsistentComponent child) {
		this.children.remove(child);

	}

	@Override
	public Set<ConsistentComponent> getChildren() {
		return this.children;
	}

	@Override
	public void updateChildren(Set<ConsistentComponent> childrenSet) {
		this.children.removeAll(this.children);
	}

}